package com.luobo.rest;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.luobo.entity.Comment;
import com.luobo.entity.Guanka;
import com.luobo.entity.News;
import com.luobo.entity.Question;
import com.luobo.entity.Tujian;
import com.luobo.service.LuoboDao;

/**
 * Task的Restful API的Controller.
 * 
 * @author guolei
 */
@Controller
@RequestMapping(value = "/api/v1/luobo")
public class LuoboRestController {

	@Resource
	private LuoboDao luoboDao;

	
	@RequestMapping(value = "guanka/{game}/{type}",method = RequestMethod.GET)
	@ResponseBody
	public List<Guanka> listGuanka(@PathVariable("game") Integer game,@PathVariable("type") Integer type) {
		return luoboDao.getGuanKaList(game, type);
	}
	
	@RequestMapping(value = "news/{game}/{page}",method = RequestMethod.GET)
	@ResponseBody
	public List<News> listNews(@PathVariable("game") Integer game,@PathVariable("page") Integer page){
		if(page == null || page <= 0){page = 1;}
		return luoboDao.getNewsList(game, page);
	}
	@RequestMapping(value = "tujian/{game}",method = RequestMethod.GET)
	@ResponseBody
	public List<Tujian> listTujian(@PathVariable("game") Integer game){
		return luoboDao.getTujianList(game);
	}
	@RequestMapping(value = "question/{game}/{page}",method = RequestMethod.GET)
	@ResponseBody
	public List<Question> listQuestion(@PathVariable("game") Integer game,@PathVariable("page") Integer page){
		if(page == null || page <= 0){page = 1;}
		return luoboDao.getQuestionList(game, page);
	}
	@RequestMapping(value = "comment/{id}",method = RequestMethod.GET)
	@ResponseBody
	public List<Comment> listComment(@PathVariable("id") Integer id){
		return luoboDao.getCommentList(id);
	}
}